import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

// 适配设计图尺寸，方法以750像素设计图计算
double fitSize(size) {
  MediaQueryData mq = MediaQueryData.fromWindow(window);
  var screenW = mq.size.width;
  double rate = screenW / 750;
  return size * rate;
}

void setStorage(String key, dynamic value) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  if(value is String) {
    prefs.setString(key, value);
  }else if(value is int) {
    prefs.setInt(key, value);
  }else if(value is double) {
    prefs.setDouble(key, value);
  }else if(value is bool) {
    prefs.setBool(key, value);
  }
}
